<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
   	#include("../../common/css.html")
    <style>
    	.form-group.has-success .form-control-feedback:before, .input-group.has-success .form-control-feedback:before {
		    color: #4285f4 !important;
		    color: inherit;
		}
    </style>
</head>

<body>
    <div class="entry">
        <div class="entry-content">
            <div class="login-wrap">

                <div class="login-box">
                    <div class="login-header">
                        <img src="#(ctx)/static/front/images/login-logo.png" alt="" class="login-logo">
                        
                    </div>
                    <div class="login-body">
                        <form method="post" name="LoginForm"  novalidate="" id="LoginForm">
                            <div class="form-group has-feddback">
                                <span class="input-icon">
                                    <input type="text" name="username" id="username" class="form-control input-lg account"
                                        placeholder="请输入您的账号"  autocomplete="off">
                                    <i class="fa fa-user darkgray"></i>
                                </span>
                            </div>
                            <div class="form-group has-feddback">
                                <span class="input-icon">
                                    
                                    <input type="text" name="password" id="password" onfocus="this.type='password'" class="form-control input-lg password"
                                        placeholder="请输入您密码" autocomplete="off">
                                    <i class="fa fa-lock darkgray"></i>
                                     <a class="pass-visible darkgray" href="#">
	                                    <i class="fa fa-eye-slash"></i>
	                                </a>
                                </span>
                            </div>
                            <div class="form-group">
                                <div class="checkbox pull-left">
                                    <label>
                                        <input type="checkbox" name="autoLogin" id="autoLogin">
                                        <span class="text">记住我</span>
                                    </label>
                                </div>
                                
                                <div class="clearfix"></div>
                            </div>
                            <button class="btn btn-block btn-primary btn-lg login-btn" type="submit">登 录</button>
                        </form>
                        
                        <div class="login-ft margin-top-20">
                            <a href="#(ctx)" class="btn-link pull-left">&lt; 返回首页</a>
                            <span class="pull-right">没有#(webinfo.site_name)帐号？
                                <a href="#(ctx)/auth/reg" class="btn-link">我要注册</a>
                            </span>
                        </div>
                    </div>
                </div>

            </div>
            <div class="entry-footer text-center">
                <p class="no-margin-bottom">#(webinfo.copy)| #(webinfo.icp) | 通讯地址：#(webinfo.addr)</p>
                <!-- <h3>400-000-0000</h3> -->
                <p>#(webinfo.worktime)</p>
            </div>
        </div>
    </div>
     #include("../../common/js.html")
    <script src="https://cdn.bootcss.com/jquery-validate/1.17.0/jquery.validate.js"></script>
	<script src="https://cdn.bootcss.com/jquery-validate/1.17.0/localization/messages_zh.min.js"></script>
    <script>
    	$(function(){
    		$(".pass-visible>i").on('click',function(){
    			if($(this).hasClass('fa-eye')){
    				$(this).removeClass('fa-eye').addClass('fa-eye-slash');
    				$(this).parents('.input-icon').find('input').attr("type","password");
    			}else{
    				$(this).removeClass('fa-eye-slash').addClass('fa-eye');
    				$(this).parents('.input-icon').find('input').attr("type","text");
    			}
    		})
    		$("#LoginForm").validate({
                errorElement: 'span',
                errorClass: 'help-block',
                rules: {
                	username: {
                        required: true
                    },
                    password: {
                        required: true,
                        minlength: 6
                    }
                },
                messages: {
                    username: {
                        required: '请输入账号'
                    },
                    password: {
                        required: "请输入密码!",
                        minlength: jQuery.validator.format("密码不能小于{0}个字 符")
                    } 
                },
                errorPlacement: function (error, element) {
                    element.next().remove();
                    element.after(
                        '<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true" style="font-size:12px;"></span>'
                    );
                    element.closest('.form-group').append(error);
                },
                highlight: function (element) {
                    $(element).closest('.form-group').addClass('has-error has-feedback');
                },
                success: function (label) {
                    var el = label.closest('.form-group').find("input");
                    el.next().remove();
                    el.after(
                        '<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" style="font-size:12px;"></span>'
                    );
                    label.closest('.form-group').removeClass('has-error').addClass(
                        "has-feedback has-success");
                    label.remove();
                },
                submitHandler:function(form){
                	var autoLogin=$("#autoLogin").is(':checked');
                	var _username=$("#username").val();
            		var _password=$("#password").val();
            		var data={username:_username,password:_password};
            		if(autoLogin){
            			data.autoLogin=1;
            		}
            		$("#btn_submit").text("登录中...");
            		$("#btn_submit").attr("disabled",true);
            		$.post("#(ctx)/auth/ajaxLogin",data,function(data){
            			layer.msg(data.msg);
            			if(data.code==0){
            				setTimeout(function(){
            					window.location.href="#(ctx)#(url)";
            				},2000);
            			}else{
            				$("#btn_submit").text("登录");
                    		$("#btn_submit").attr("disabled",false);
            			}
            		},'json');
                	
                }
            });
    	});
    </script>
</body>

</html>